package com.xcity.game.battle.pve.employee.impl;

import com.xcity.game.battle.pve.PlayerBattler;
import com.xcity.game.battle.pve.employee.EmployeeSkillBattleContext;
import com.xcity.game.common.GameStaticConfig;
import com.xcity.game.employee.skill.EmployeeSkill;

public class INVINCIBLE_LAST_N_TIMES_CONTEXT extends EmployeeSkillBattleContext {

	private boolean valid;
	
	public INVINCIBLE_LAST_N_TIMES_CONTEXT(PlayerBattler player, EmployeeSkill ref) {
		super(player, ref);
		int n = rnd.nextInt(GameStaticConfig.percentBase);
		if (n < ref.getTemplate().getInitVal(0)) {
			valid = true;
		}
	}

	@Override
	public boolean trigger() {
		if (valid) {
			if (++triggeredTimes > ref.getTemplate().getInitVal(1)) {
				valid = false;
			}
			return true;
		}
		return false;
	}

}
